using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace WeberTimeTracker.Models.Mapping
{
    public class ZipMap : EntityTypeConfiguration<Zip>
    {
        public ZipMap()
        {
            // Primary Key
            this.HasKey(t => t.Zip_ID);

            // Properties
            this.Property(t => t.First_5)
                .IsRequired()
                .IsFixedLength()
                .HasMaxLength(5);

            this.Property(t => t.Last_4)
                .IsFixedLength()
                .HasMaxLength(4);

            // Table & Column Mappings
            this.ToTable("Zips");
            this.Property(t => t.Zip_ID).HasColumnName("Zip_ID");
            this.Property(t => t.First_5).HasColumnName("First_5");
            this.Property(t => t.Last_4).HasColumnName("Last_4");
        }
    }
}
